<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<%@ include file="/common-app/taglibs.jsp"%>
<x:parse xml="${param.xmlstr}" var="xmlData" />


<div class="t_bar2"><span class="color_red">*</span>企业引进情况</div>
<table id="tblServiceContents" cellpadding="0" class="t_css" width="100%"
	border="0" cellpadding="0" style="*border-bottom: #a1c0dc 1px solid;">
		<tr style="border: 1px solid #B7D1E6">
			<td class="TblHead" align="center" width="2%" rowspan="2">选择</td>
			<td class="TblHead" align="center" width="2%" rowspan="2">序号</td>
			<td class="TblHead" align="center" width="8%" rowspan="2">单位名称</td>
			<td class="TblHead" align="center" width="8%" rowspan="2">机构类型</td>
			<td class="TblHead" align="center" width="8%" colspan="2">投资额<br/>（万元）</td>
			<td class="TblHead" align="center" width="10%" rowspan="2">注册日期</td>
			<td class="TblHead" align="center" width="9%" colspan="2">人员情况</td>
			<td class="TblHead" align="center" width="12%" colspan="2">税收贡献<br/>（万元）</td>
			<td class="TblHead" align="center" width="8%" colspan="2">实现利润<br/>（万元）</td>
			<td class="TblHead" align="center" width="15%" colspan="3">办公用房<br/>面积（㎡）</td>
			<td class="TblHead" align="center" width="16%" colspan="2">政策兑<br/>现情况</td>
			
		</tr>
		<tr style="border: 1px solid #B7D1E6">
			<td class="TblHead" align="center" width="5%">注册<br/>资本</td>
			<td class="TblHead" align="center" width="5%">实收<br/>资本</td>
			<td class="TblHead" align="center" width="5%">单位<br/>人数</td>
			<td class="TblHead" align="center" width="5%">高管<br/>人员数</td>
			<td class="TblHead" align="center" width="5%">当年</td>
			<td class="TblHead" align="center" width="5%">上年</td>
			<td class="TblHead" align="center" width="5%">当年</td>
			<td class="TblHead" align="center" width="5%">上年</td>
			<td class="TblHead" align="center" width="5%">自建</td>
			<td class="TblHead" align="center" width="5%">租赁</td>
			<td class="TblHead" align="center" width="5%">购买</td>
			<td class="TblHead" align="center" width="7%">金额<br/>（万元）</td>
			<td class="TblHead" align="center" width="7%">具体<br/>构成</td>
		</tr>
		<tr style="display: none">
			<td align="center"><input type="radio" class="radiobutton" name="selServiceContents"></td>
			<td align="center"><span name="servicecontents|servicecontent[0]@seq_no">[index]</span></td>
			<td style="text-align: center;"><input type="text" style="width: 80%"
				name="servicecontents|servicecontent[0]|org_name" class="input_text required"
				maxlength=100 label="单位名称" value="" />
			</td>
			<td style="text-align: center;"><input type="text" style="width:80%"
				name="servicecontents|servicecontent[0]|org_type" class="input_text required"
				maxlength=100 label="机构类型" value="" />
			</td>
			<td style="text-align: center;"><input type="text" style="width:70%;"   onfocus="InitInput.setNumber(this,9,4,2)"
				name="servicecontents|servicecontent[0]|regist_fund" class="input_text required"
				maxlength=100 label="注册资本" value="" />
			</td>
			<td style="text-align: center;"><input type="text" style="width:70%"  onfocus="InitInput.setNumber(this,9,4,2)"
				name="servicecontents|servicecontent[0]|capital_fund" class="input_text required"
				maxlength=100 label="实收资本" value="" />
			</td>
			
			<td align="center" nowrap><input  id="servicecontent_start_date_[0]" name="servicecontents|servicecontent[0]|start_date" label="注册日期" value="" class=" required input_text date " style="width:65px" /></td>
			<td style="text-align: center;"><input type="text" style="width:70%"  onfocus="InitInput.setNumber(this,9,0,0)"
				name="servicecontents|servicecontent[0]|org_person_total" class="input_text required"
				maxlength=100 label="单位人数" value="" />
			</td>
			<td style="text-align: center;"><input type="text"  style="width:70%"   onfocus="InitInput.setNumber(this,9,0,0)"
				name="servicecontents|servicecontent[0]|senior_executive_total" class="input_text required"
				maxlength=100 label="高管人员数" value="" />
			</td>
			<td style="text-align: center;"><input type="text"  style="width:70%"   onfocus="InitInput.setNumber(this,9,4,2)"
				name="servicecontents|servicecontent[0]|design_year_tax" class="input_text required"
				maxlength=100 label="税收贡献-->当年" value="" />
			</td>
			<td style="text-align: center;"><input type="text"  style="width:70%"   onfocus="InitInput.setNumber(this,9,4,2)"
				name="servicecontents|servicecontent[0]|last_year_tax" class="input_text required"
				maxlength=100 label="税收贡献-->上年" value="" />
			</td>
			<td style="text-align: center;"><input type="text"  style="width:70%"   onfocus="InitInput.setNumber(this,9,4,2)"
				name="servicecontents|servicecontent[0]|design_year_profit" class="input_text required"
				maxlength=100 label="实现利润-->当年" value="" />
			</td>
			<td style="text-align: center;"><input type="text"  style="width:70%"   onfocus="InitInput.setNumber(this,9,4,2)"
				name="servicecontents|servicecontent[0]|last_year_profit" class="input_text required"
				maxlength=100 label="实现利润-->上年" value="" />
			</td>
			<td style="text-align: center;"><input type="text"  style="width:70%"   onfocus="InitInput.setNumber(this,9,4,2)"
				name="servicecontents|servicecontent[0]|build_self_area" class="input_text required"
				maxlength=100 label="办公用房面积-->自建" value="" />
			</td>
			<td style="text-align: center;"><input type="text"  style="width:70%"   onfocus="InitInput.setNumber(this,9,4,2)"
				name="servicecontents|servicecontent[0]|least_area" class="input_text required"
				maxlength=100 label="办公用房面积-->租赁" value="" />
			</td>
			<td style="text-align: center;"><input type="text"  style="width:70%"   onfocus="InitInput.setNumber(this,9,4,2)"
				name="servicecontents|servicecontent[0]|buy_area" class="input_text required"
				maxlength=100 label="办公用房面积-->购买" value="" />
			</td>
			<td style="text-align: center;"><input type="text"  style="width:80%"   onfocus="InitInput.setNumber(this,9,4,2)"
				name="servicecontents|servicecontent[0]|honor_fund" class="input_text required"
				maxlength=100 label="政策兑现情况-->金额" value="" />
			</td>
			<td style="text-align: center;"><input type="text" style="width:80%"
				name="servicecontents|servicecontent[0]|constitute_info" class="input_text required"
				maxlength=100 label="政策兑现情况-->具体构成" value="" />
			</td>
		</tr>
		<c:set value="0" var="index" scope="page" />
		<x:forEach select="$xmlData/data/servicecontents/servicecontent" var="servicecontent">

			<c:choose>
				<c:when test="${index<10}">
					<c:set value="0" var="flag" scope="page" />
				</c:when>
				<c:otherwise>
					<c:set value="" var="flag" scope="page" />
				</c:otherwise>
			</c:choose>
			<tr>
				<td align="center"><input type="radio" class="radiobutton"
					name="selServiceContents">
				</td>
				<td align="center"><span
					name="servicecontents/servicecontent[${flag}${index}]@seq_no">${index+1}</span></td>
				<td style="text-align: center;"><input type="text" style="width:80%"
					name="servicecontents/servicecontent[${flag}${index}]/org_name"
					class="input_text required" maxlength=100 label="单位名称"
					value="<x:out select="$servicecontent/org_name" />" />
				</td>
				
			<td style="text-align: center;"><input type="text" style="width:80%"
					name="servicecontents/servicecontent[${flag}${index}]/org_type"
					class="input_text required" maxlength=100 label="机构类型"
					value="<x:out select="$servicecontent/org_type" />" />
				</td>
				<td style="text-align: center;"><input type="text" style="width:70%"
					name="servicecontents/servicecontent[${flag}${index}]/regist_fund"
					class="input_text required" maxlength=100 label="注册资本"  onfocus="InitInput.setNumber(this,9,4,2)"
					value="<x:out select="$servicecontent/regist_fund" />" />
				</td>
				<td style="text-align: center;"><input type="text" style="width:70%"
					name="servicecontents/servicecontent[${flag}${index}]/capital_fund"
					class="input_text required" maxlength=100 label="实收资本"  onfocus="InitInput.setNumber(this,9,4,2)"
					value="<x:out select="$servicecontent/capital_fund" />" />
				</td>
				<td align="center" nowrap><c:set var="start_date" scope="page"><x:out select="$servicecontent/start_date"/></c:set>
				<input  id="servicecontent_start_date_[${flag}${index}]" value="${start_date}" name="servicecontents/servicecontent[${flag}${index}]/start_date" 
					class="required date input_text" style="width:65px" label="注册日期" /> 
				</td>
				<td style="text-align: center;"><input type="text" style="width:70%"
					name="servicecontents/servicecontent[${flag}${index}]/org_person_total"
					class="input_text required" maxlength=100 label="单位人数"  onfocus="InitInput.setNumber(this,9,0,0)"
					value="<x:out select="$servicecontent/org_person_total" />" />
				</td>
				<td style="text-align: center;"><input type="text" style="width:70%"
					name="servicecontents/servicecontent[${flag}${index}]/senior_executive_total"
					class="input_text required" maxlength=100 label="高管人员数"  onfocus="InitInput.setNumber(this,9,0,0)"
					value="<x:out select="$servicecontent/senior_executive_total" />" />
				</td>
				<td style="text-align: center;"><input type="text" style="width:70%"
					name="servicecontents/servicecontent[${flag}${index}]/design_year_tax"
					class="input_text required" maxlength=100 label="税收贡献-->当年"  onfocus="InitInput.setNumber(this,9,4,2)"
					value="<x:out select="$servicecontent/design_year_tax" />" />
				</td>
				<td style="text-align: center;"><input type="text" style="width:70%"
					name="servicecontents/servicecontent[${flag}${index}]/last_year_tax"
					class="input_text required" maxlength=100 label="税收贡献-->上年"  onfocus="InitInput.setNumber(this,9,4,2)"
					value="<x:out select="$servicecontent/last_year_tax" />" />
					
				</td>
				<td style="text-align: center;"><input type="text" style="width:70%"
					name="servicecontents/servicecontent[${flag}${index}]/design_year_profit"
					class="input_text required" maxlength=100 label="实现利润-->当年"  onfocus="InitInput.setNumber(this,9,4,2)"
					value="<x:out select="$servicecontent/design_year_profit" />" />
					
				</td>
				<td style="text-align: center;"><input type="text" style="width:70%"
					name="servicecontents/servicecontent[${flag}${index}]/last_year_profit"
					class="input_text required" maxlength=100 label="实现利润-->上年"  onfocus="InitInput.setNumber(this,9,4,2)"
					value="<x:out select="$servicecontent/last_year_profit" />" />
					
				</td>
				<td style="text-align: center;"><input type="text" style="width:70%"
					name="servicecontents/servicecontent[${flag}${index}]/build_self_area"
					class="input_text required" maxlength=100 label="办公用房面积-->自建"  onfocus="InitInput.setNumber(this,9,4,2)"
					value="<x:out select="$servicecontent/build_self_area" />" />
					
				</td>
				<td style="text-align: center;"><input type="text" style="width:70%"
					name="servicecontents/servicecontent[${flag}${index}]/least_area"
					class="input_text required" maxlength=100 label="办公用房面积-->租赁"  onfocus="InitInput.setNumber(this,9,4,2)"
					value="<x:out select="$servicecontent/least_area" />" />
					
				</td>
				<td style="text-align: center;"><input type="text" style="width:70%"
					name="servicecontents/servicecontent[${flag}${index}]/buy_area"
					class="input_text required" maxlength=100 label="办公用房面积-->购买"  onfocus="InitInput.setNumber(this,9,4,2)"
					value="<x:out select="$servicecontent/buy_area" />" />
					
				</td>
				<td style="text-align: center;"><input type="text" style="width:80%"
					name="servicecontents/servicecontent[${flag}${index}]/honor_fund"
					class="input_text required" maxlength=100 label="政策兑现情况-->金额"  onfocus="InitInput.setNumber(this,9,4,2)"
					value="<x:out select="$servicecontent/honor_fund" />" />
					
				</td>
				<td style="text-align: center;"><input type="text" style="width:80%"
					name="servicecontents/servicecontent[${flag}${index}]/constitute_info"
					class="input_text required" maxlength=100 label="政策兑现情况-->具体构成" 
					value="<x:out select="$servicecontent/constitute_info" />" />
					
				</td>
				
			</tr>
			<c:set value="${index+1}" var="index" scope="page" />
		</x:forEach>
		<script type="text/javascript">
						showAllDateTag("tblServiceContents");
		</script>
</table>
<table width="100%" align="center">
	<tr>
		<td colspan="8"><input class="button" name="cmdAddbefore" type=button value="添加"
			onclick="if(checkTabLimitRewrite('tblServiceContents',99,'最多只能添加99条企业引进信息')){addNewRowRewrite('tblServiceContents');showDateTag('tblServiceContents');try{top.resizeFrame();}catch(e){};}">
			<input class="button" name="cmdMovePrev"
			type=button value="上移"
			onclick="movePrevRewrite('tblServiceContents')"> <input
			class="button" name="cmdMoveNext" type=button value="下移"
			onclick="moveNextRewrite('tblServiceContents')"> <input
			class="button" name="cmddel" type=button value="删除"
			onclick="deleteSelectedRowRewrite('tblServiceContents','已并购境外研发机构拥有知识产权情况')"></td>
	</tr>
	</table>
</div>
<script type="text/javascript">
/**
 * 增加一行（重写）
 * @param tableId表格Id
 * @param radioId
 * @param nNewRowPosition
 * @param startRowIndex
 */
function addNewRowRewrite(tableId)
{
	var table = $("#"+tableId);
	var maxLinNum=table.find("tr").length-3;//获得行数，减去2行表头和隐藏行
	var lineNum=""+(maxLinNum+1);
	
	var addHtml=table.find("tr")[2].innerHTML;//获得隐藏行的html,查找第三行
	addHtml=addHtml.replace(/\[index\]/g,lineNum);
	lineNum = (parseInt(lineNum, 10)-1).toString();//2011.12.13 行下标比行号小1(隐藏行下标[0]，第一行下标[00])
	if (lineNum.length==1)//如果是个位数，前面补0
		lineNum="0"+lineNum;
	addHtml=addHtml.replace(/\[0\]/g,"["+lineNum+"]");//替换html中行号
	addHtml=addHtml.replace(/\|/g,"/");//替换html中节点/的代替符"|"
	table.append("<tr>"+addHtml+"</tr>");//将html增加到最后
	
}
/**
 * 上移行(重写)
 * @param tblId
 * @returns {Boolean}
 */
function movePrevRewrite(tblId,selName) {

	if (!selName)
		selName = "";
	if ($("#" + tblId + " :radio[name*='" + selName + "']:checked").length == 0) {
		scmWarn(irisNotes.prevWarn);
		return false;
	}
	if ($("#" + tblId + " tr").length <= 3)
		return false;
	var trChecked = $("#" + tblId + " :radio[name*='" + selName + "']:checked")
			.parents("tr").first();// 取得被选中的行
	var trPrev = trChecked.prev();// 取得上一行
	var index = trChecked.get(0).rowIndex;// 获得行号
	if (index <= 3) {// 如果是第一行
		scmWarn(irisNotes.tabelMoveWarn1);
		return false;
	}
	//trChecked.remove();
	trPrev.before(trChecked);
	trChecked.find(":radio[name*='" + selName + "']").attr("checked", 'true');
	refreshRowINdexRewrite(tblId);//刷新行号
}


 /**
  * 下移行(重写)
  * @param tblId
  * @returns {Boolean}
  */
 function moveNextRewrite(tblId,selName) {
 	if (!selName)
 		selName = "";
 	if ($("#" + tblId + " :radio[name*='" + selName + "']:checked").length == 0) {
 		scmWarn(irisNotes.nextWarn);
 		return false;
 	}
 	if ($("#" + tblId + " tr").length <= 3) {
 		return false;
 	}
 	var trChecked = $("#" + tblId + " :radio[name*='" + selName + "']:checked")
 			.parents("tr").first();// 取得被选中的行
 	var trNext = trChecked.next();
 	var index = trChecked.get(0).rowIndex;// 获得行号
 	if (index == $("#" + tblId + " tr").length - 1) {// 如果是第一行
 		scmWarn(irisNotes.tabelMoveWarn2);
 		return false;
 	}
 	//trChecked.remove();
 	trNext.after(trChecked);
 	trChecked.find(":radio[name*='" + selName + "']").attr("checked", "true");
 	refreshRowINdexRewrite(tblId);//刷新行号
 }
  
 /**
  * 删除一行
  * @param radioId 
  */
 function deleteSelectedRowRewrite(tableId,message,nummin,warnMsg,selName){
 	if(!selName)selName="";
 	var tr=$("#"+tableId+" :radio[name*='"+selName+"']:checked").parents("tr");
 	if(nummin==null)
 		nummin=0;
 	var length=tr.length;
 	if(tr.length==0)
 		tr=$("#"+tableId+" tr").filter(":last");
 	else if(tr.length>1)
 		tr=tr.first();

 	if(tr.get(0).rowIndex-1==nummin){
 		scmWarn(irisNotes.delWarn1);
 		return false;
 	}
 	if(length==0){
 		
 			scmWarn(irisNotes.delWarn2);
 		
 		return false;
 	}
 	  if(!confirm(messageTip.deleteTip+message+"？"))
 		  return false;
 	  tr.remove();
 	  refreshRowINdexRewrite(tableId);//刷新行号
 	
 	return true;
 }
  
 /**
  * 重新计算行号（重写）
  * @param tblId
  */
 function refreshRowINdexRewrite(tblId){
 	 //重新计算行号
 	  $("#"+tblId+" tr").each(function(){
 		   var seq=$(this).get(0).rowIndex;//获得行数
 		   if(seq>2){//如果有行  显示时display行不计入类，故只减2
 			   
 			   seq=seq-2;
 			   var seq_no=$(this).find("[name$='seq_no']");
 			   if(seq_no.is("span"))
 				   seq_no.html(seq);
 			   else
 				   seq_no.val(seq);
 			   
 			   seq=""+(seq-1);
 			   if(seq.length==1)
 				   seq="0"+seq;
 			  //替换相应的name参数的seq
 			  $(this).find("input,span,textarea,select").each(function(){
 				   var name=$(this).attr("name");
 				   if(name!=null&&name!=""){
 					   name=name.replace(/\[\d*\]/g,"["+seq+"]");
 					   $(this).attr("name",name);
 				   }
 				   var id=$(this).attr("id");
 				   if(id!=null&&id!=""){
 					   id=id.replace(/\[\d*\]/g,"["+seq+"]");
 					   $(this).attr("id",id);
 				   }
 				   var className=$(this).attr("class");
 				   if(className!=null&&className!=""){
 					   className=className.replace(/\[\d*\]/g,"["+seq+"]");
 					   $(this).attr("class",className);
 				   }
 			   });
 		   }
 		 }
 	  );

 }
 
 /**
  * 限制Table行数 （重写）
  * @param tableId表格id
  * @param max最大行数
  * @returns {Boolean}
  */
 function checkTabLimitRewrite(tableId,max,message)
 {
 	var maxLinNum=$("#"+tableId+" tr").length-3;
 	
 		if(maxLinNum>=max)
 		{
 			scmWarn(message);
 			return false;
 		}
 	return true;
 }
</script>
